package com.it.user.api;

import com.it.user.entity.User;
import com.it.user.service.UserService;
import com.it.user.vo.UserVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 用户的实现
 */
@DubboService(version = "${user.service.version}")
public class ApiUserImpl implements UserApi {
    @Autowired
    private UserService userService;
    public void addUser(UserVO userVO) {
        User user = new User();
        BeanUtils.copyProperties(userVO,user);
        userService.insert(user);
    }

    public void delUserByUserId(long userId) {
        userService.deleteById(userId);
    }

    public void updateUserByUserId(UserVO userVO) {
        User user = new User();
        BeanUtils.copyProperties(userVO,user);
        userService.updateById(user);
    }

    public UserVO queryUserByUserId(long userId) {
        UserVO userVO = new UserVO();
        User user =userService.selectById(userId);
        BeanUtils.copyProperties(user,userVO);
        return userVO;
    }
}
